refactor: derive database URIs from a single MONGODB_URI base#113
Open
m4nojTudu wants to merge 1 commit intoTiledesk:masterfrom
Open
refactor: derive database URIs from a single MONGODB_URI base#113m4nojTudu wants to merge 1 commit intoTiledesk:masterfrom
m4nojTudu wants to merge 1 commit intoTiledesk:masterfrom
Conversation
- Replace hardcoded localhost URIs with buildDbUri helper - Logs and test databases now follow the primary connection string - Add env var support for JWT_SECRET - MONGODB_URI_LOGS and MONGODB_URI_TEST remain optional overrides - Backward compatible: defaults unchanged when no env vars are set - Add unit tests for buildDbUri
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replaces hardcoded MongoDB connection strings in
config/database.jswith a
buildDbUrihelper that derivesdatabaselogsanddatabasetestURIs from the primary connection string.
Why
When deploying against a remote cluster (e.g.
mongodb+srv://), the logsand test databases still pointed at localhost unless their dedicated env
vars were set. This makes them automatically follow the primary URI.
Backward compatibility
localhost:27017defaults as beforeMONGODB_URI_LOGS/MONGODB_URI_TESTremain optional overridesconfig.database,config.databaselogs,or
config.databasetestHow to test
npx mocha test/config/buildDbUri.test.js
Note
Low Risk
Configuration-only change with small, well-tested string parsing; main risk is misconstructed URIs for uncommon MongoDB connection string formats.
Overview
Refactors
config/database.jsto builddatabaselogsanddatabasetestURIs from the primaryMONGODB_URI(falling back to the existing localhost default), instead of hardcoding separate localhost connection strings.Adds a
buildDbUri()helper that swaps/creates the database path while preserving query params, makessecretconfigurable viaJWT_SECRET, and introduces Mocha tests covering common MongoDB URI formats and edge cases.Written by Cursor Bugbot for commit 444c9fa. This will update automatically on new commits. Configure here.